package fr.appliClient.server.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import fr.appliClient.server.dao.ConsumptionDao;
import fr.appliClient.server.entity.Consumption;

/**
 * Service for consumption.
 * 
 * @author remi
 * 
 */
@Service
public class ConsumptionService {

	/**
	 * 
	 */
	private static final long serialVersionUID = 7201948463864587912L;

	@Autowired
	private ConsumptionDao dao;

	/**
	 * Create or update a consumption.
	 * 
	 * @param consumption
	 * @return
	 */
	public Consumption saveConsumption(Consumption consumption) {

		Consumption savedConsumption = this.dao.save(consumption);
		return savedConsumption;
	}

	/**
	 * Delete a consumption.
	 * 
	 * @param consumption
	 */
	public void removeConsumption(Consumption consumption) {

		this.dao.delete(consumption);
	}

	public List<Consumption> getConsumptionByVehicle(String vehicleId) {

		return this.dao.findByVehicle(vehicleId);
	}
}
